package org.example.shop_front_api.entity;

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.persistence.Id;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.stereotype.Component;

@Component
@Data
@NoArgsConstructor
@AllArgsConstructor
@Document(indexName = "es_goods_list")
public class ESGoods {

    //映射的_id
    @Id
    private Long id;

    @Field(name = "goods_name", type = FieldType.Text, analyzer = "ik_max_word")
    private String goodsName;

    @JsonProperty("first_cate_id")
    @Field(name = "first_cate_id", type = FieldType.Integer)
    private int firstCateId;

    @JsonProperty("second_cate_id")
    @Field(name = "second_cate_id", type = FieldType.Integer)
    private int secondCateId;

    @JsonProperty("third_cate_id")
    @Field(name = "third_cate_id", type = FieldType.Integer)
    private int thirdCateId;

    @JsonProperty("sales_number")
    @Field(name = "sales_number", type = FieldType.Integer)
    private double salesNumber;

    @JsonProperty("sale_price")
    @Field(name = "sale_price", type = FieldType.Double)
    private double salePrice;

    @JsonProperty("main_image")
    @Field(name = "main_image", type = FieldType.Text)
    private String mainImage;

    public String getMainImage() {
        return mainImage;
    }

    public void setMainImage(String mainImage) {
        this.mainImage = mainImage;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public int getFirstCateId() {
        return firstCateId;
    }

    public void setFirstCateId(int firstCateId) {
        this.firstCateId = firstCateId;
    }

    public int getSecondCateId() {
        return secondCateId;
    }

    public void setSecondCateId(int secondCateId) {
        this.secondCateId = secondCateId;
    }

    public int getThirdCateId() {
        return thirdCateId;
    }

    public void setThirdCateId(int thirdCateId) {
        this.thirdCateId = thirdCateId;
    }

    public double getSalesNumber() {
        return salesNumber;
    }

    public void setSalesNumber(double salesNumber) {
        this.salesNumber = salesNumber;
    }

    public double getSalePrice() {
        return salePrice;
    }

    public void setSalePrice(double salePrice) {
        this.salePrice = salePrice;
    }

    @Override
    public String toString() {
        return "ESGoods{" +
                "id=" + id +
                ", goodsName='" + goodsName + '\'' +
                ", firstCateId=" + firstCateId +
                ", secondCateId=" + secondCateId +
                ", thirdCateId=" + thirdCateId +
                ", salesNumber=" + salesNumber +
                ", salePrice=" + salePrice +
                ", mainImage=" + mainImage +
                '}';
    }
}
